import 'package:flutter/material.dart' as ui;
import '../base/axis.dart';

/// 附加线
///
/// Created by wanggaowan on 2023/9/15 15:45
class AddedLine {
  AddedLine(
      {required this.value,
      this.lineColor = ui.Colors.green,
      this.lineWidth = 1,
      this.label,
      this.labelTextSize = 12,
      this.labelTextColor = ui.Colors.black,
      this.labelAlignment = ui.Alignment.topRight,
      this.useStartPadding = true,
      this.useEndPadding = true,
      this.lineDash,
      this.textOverflow = ui.TextOverflow.ellipsis})
      : assert(lineWidth > 0, "line width must than zero");

  /// 附加线值，作用于Y轴时，其值介于[YAxis.min]和[YAxis.max]之间。
  /// 作用于X轴时，其值介于[0]和[Axis.labelCount] - 1之间。
  /// 绘制时取当前值占区间大小的百分比进行位置计算
  final double value;

  /// 附加线颜色
  final ui.Color lineColor;

  /// 附加线宽度
  final double lineWidth;

  /// 附加线文本
  final String? label;

  /// 附加线文本字体大小
  final double labelTextSize;

  /// 附加线文本字体颜色
  final ui.Color labelTextColor;

  /// 附加线文本绘制位置，以附加线作为基准
  final ui.Alignment labelAlignment;

  /// [Axis.endPadding]属性是否作用于附加线，如果此值为true,那么附加线绘制长度<=x轴轴线长度
  final bool useEndPadding;

  /// [Axis.startPadding]属性是否作用于附加线，如果此值为true,那么附加线绘制长度<=x轴轴线长度
  final bool useStartPadding;

  /// 线条路径样式
  final List<double>? lineDash;

  /// 标签超出最大行数后缺省模式，暂不支持[TextOverflow.fade]
  final ui.TextOverflow textOverflow;

  /// 附加线线绘制的矩形区域
  ui.Rect get drawRect => _drawRect;
  ui.Rect _drawRect = ui.Rect.zero;

  /// 非自定义绘制，请不要主动赋值
  set $drawRect(ui.Rect rect) => _drawRect = rect;
}
